/**
 * 
 */
var gcCM = new Ext.grid.ColumnModel([
 	new Ext.grid.RowNumberer(), {
	header : '编号',
	width : 50,
	dataIndex : 'id',
	sortable : true,
	align:'center',
	id : 'idGC'
}, {
	header : '模型项目名',
	width : 150,
	dataIndex : 'groupName',
	sortable : true,
	align : 'center'
}, {
	header : '版本',
	width : 50,
	dataIndex : 'version',
	sortable : true,
	align : 'center'
},{
	header:'WADL转换',
	width:80,
	dataIndex:'wadl',
	sortable:true,
	renderer:renderWadl
	
},{
	header:'WSDL转换',
	width:80,
	sortable:true,
	dataIndex:'wsdl',
	renderer:renderWsdl

},{
	header:'BPMN转换',
	width:80,
	dataIndex:'bpmn',
	sortable:true,
	renderer:renderBpmn

},{
	header:'BPEL转换',
	width:80,
	sortable:true,
	dataIndex:'bpel',
	renderer:renderBpel

},{
	header:'导出至ORIPS',
	width:100,
	sortable:true,
	dataIndex:'W2O',
	renderer:renderW2O

},{
	header:'添加WSLA描述',
	width:100,
	sortable:true,
	dataIndex:'WSLA',
	renderer:renderWSLA

},{
	header:'上传SLA文件',
	width:100,
	sortable:true,
	dataIndex:'SLA',
	renderer:renderSLA
} ]);

function renderWadl(value, cellmeta, record, rowIndex, columnIndex, store) {  

	
	return"<input type='button' onclick=''  value='转换WADL' />";
   
	
}
function renderWsdl(value, cellmeta, record, rowIndex, columnIndex, store) {  

	
	return"<input type='button' onclick=''  value='转换WSDL' />";
   
	
}
function renderBpmn(value, cellmeta, record, rowIndex, columnIndex, store) {  

	
	return"<input type='button' onclick=''  value='转换BPMN' />";
   
	
}
function renderBpel(value, cellmeta, record, rowIndex, columnIndex, store) {  

	
	return"<input type='button' onclick=''  value='转换BPEL' />";
   
	
}
function renderW2O(value, cellmeta, record, rowIndex, columnIndex, store) {  

	
	return"<input type='button' onclick=''  value='导出至ORIPS' />";
   
	
}

function renderWSLA(value, cellmeta, record, rowIndex, columnIndex, store) {  	
	return"<input type='button' onclick=''  value='添加WSLA描述' />";  
}

function renderSLA(value, cellmeta, record, rowIndex, columnIndex, store) {  	
	return"<input type='button' onclick=''  value='上传SLA文件' />";  
}

var gcStore=new Ext.data.Store({
	proxy : new Ext.data.HttpProxy({
		url : 'showCompanyModelgroupList',
		method : 'post'
	}),
	reader : new Ext.data.JsonReader({
		root : 'ModelgroupVO',
		totalProperty : 'totalModelgroupVO',
		id : 'id'
	}, [{
		name : 'id'
	}, {
		name : 'groupName'
	}, {
		name : 'description'
	}, {
		name : 'version'
	}])
});




var gcList = new Ext.grid.GridPanel({
	enableColumnResize : true,
	id:'transform-panel',
	border : true,
	title:'模型转换',
	clicksToEdit : 1,
	enableColumnMove : true,
	enableHdMenu : false,
	stripeRows : true, // 显示斑马线
	loadMask : true,
	//autoHeight : true,
	bodyStyle : 'width:100%;height:100%',
	autoScroll:true,
	autoWidth : true,
	editable : true,
	showPage:function(){
	gcStore.load({
		params : {
			start : 0,
			limit : 20
		}
	});
             },
    store : gcStore,
	cm : gcCM,
	
	listeners: {  
		 'cellclick':function(grid,rowIndex,columnIndex,e ){
			 var record = grid.getStore().getAt(rowIndex); //Get the Record
			 var fieldName = grid.getColumnModel()  
             .getDataIndex(columnIndex);  
			 //alert(record.get("groupName"));
			 if (fieldName=="wadl"){
				 Ext.Ajax.request({
						method : 'POST',// 后台路径
						url : 'generateWadlAction',// 向后台传递参数
						params : {
							nodeName : record.get("groupName"),
							nodeVersion: record.get("version")
						},
						success : function(request) {
							var xmldata;
							xmldata = request.responseText;
						
							Ext.Msg.alert('Generate Wadl', xmldata);
						}

					});
				 
			 }
			 else if (fieldName=="bpmn"){
				 Ext.Ajax.request({
						method : 'POST',// 后台路径
						url : 'generateBpmnAction',// 向后台传递参数
						params : {
							nodeName : record.get("groupName"),
							nodeVersion: record.get("version")
						}
						

					});
			 }
			 else if (fieldName=="bpel"){
				 Ext.Ajax.request({
						method : 'POST',// 后台路径
						url : 'generateBpelAction',// 向后台传递参数
						params : {
							nodeName : record.get("groupName"),
							nodeVersion: record.get("version")
						}
						

					});
			 } 
			 else if (fieldName=="wsdl"){
				 Ext.Ajax.request({
						method : 'POST',// 后台路径
						url : 'generateWsdlAction',// 向后台传递参数
						params : {
							nodeName : record.get("groupName"),
							nodeVersion: record.get("version")
						}
						

					});
			 } 
			 else if (fieldName=="W2O"){
				 Ext.Ajax.request({
						method : 'POST',// 后台路径
						url : 'exportOripsAction',// 向后台传递参数
						params : {
							nodeName : record.get("groupName"),
							nodeVersion: record.get("version")
						}
						

					});
			 } 
			 else if (fieldName=="WSLA"){
				 
				 slaPanel.groupId=record.get("id");
				 slaPanel.groupName=record.get("groupName");
				 slaPanel.version=record.get("version");
				 
				 contentPanel.addTab('sla-panel');
				 slaPanel.showPage();
			 }
			 else if (fieldName=="SLA"){
				 slaUploadWin.modelgroupId=record.get("id");
				 slaUploadWin.show();
			 }
		 }   
		 },
//	tbar:[
//	      '模型列表:',	      
//	      new Ext.form.TextField({
//	    		id:'goupId-gc',
//	    		name:'文件名',
//	    		width:210,
//	    		allowblank:false,
//	    		enableKeyEvents:true
//	      }),{xtype : "tbseparator"},{
//	  		text : '转换WADL',
//			xtype: 'button',
//			iconCls : 'db-icn-upload_',
//			handler : function() {
//                 if (Ext.util.Format.trim(Ext.getCmp('goupId-gc').getValue()).length==0)
//					 Ext.Msg.alert('没有选择源文件', '请选者信息模型文件后再次提交');
//                 else {
//                	 Ext.Ajax.request({
//     					method : 'POST',// 后台路径
//     					url : 'generateWadlAction',// 向后台传递参数
//     					params : {
//     						nodeName : Ext.getCmp('goupId-gc').getValue()
//     					},
//     					success : function(request) {
//     						xmldata = request.responseText;
//     						xmldata = xmldata.replace("{" + "\"", "");
//     						xmldata = xmldata.replace("}", "");
//     						xmldata = xmldata.replace("warnning" + "\"" + ":", "");
//     						Ext.Msg.alert('Generate Wadl', xmldata, null,
//     								null);
//     					}
//
//     				});
//                 }
//				
//			},
//			scope : this
//		}
////			,{
////	  		text : '生成rest',
////			xtype: 'button',
////			iconCls : 'db-icn-upload_',
////			handler : function() {
////                 if (Ext.util.Format.trim(Ext.getCmp('fileId-tf').getValue()).length==0)
////					 Ext.Msg.alert('没有选择源文件', '请选者信息模型文件后再次提交');
////                 else {
////                	 Ext.Ajax.request({
////     					method : 'POST',// 后台路径
////     					url : 'generateWadlAction',// 向后台传递参数
////     					params : {
////     						nodeName : Ext.getCmp('fileId-tf').getValue()
////     					},
////     					success : function(request) {
////     						xmldata = request.responseText;
////     						xmldata = xmldata.replace("{" + "\"", "");
////     						xmldata = xmldata.replace("}", "");
////     						xmldata = xmldata.replace("warnning" + "\"" + ":", "");
////     						Ext.Msg.alert('Generate Wadl', xmldata, null,
////     								null);
////     					}
////
////     				});
////                 }
////				
////			},
////			scope : this
////		}
//	      ],
	      bbar: new Ext.PagingToolbar({//下面的分页条
	          pageSize: 20,
	          store: gcStore,
	          displayInfo: true,
	          displayMsg: '当前显示第 {0} 条到 {1} 条记录，一共 {2} 条',
	          emptyMsg: "没有记录",
	          lastText:"尾页",   
	          nextText :"下一页",   
	          prevText :"上一页",   
	          firstText :"首页",   
	          refreshText:"刷新页面"        
	      })


});